package com.kob.backend.utils;

import lombok.Getter;

@Getter
public enum ResultEnum {
    SUCCESS(200, "success"),
    FAIL(500, "fail"),

    USERNAME_EMPTY(400100, "用户名不能为空"),
    PASSWORD_EMPTY(400101, "密码不能为空"),
    USERNAME_LENGTH(400102, "用户名长度不能大于100"),
    PASSWORD_LENGTH(400103, "密码长度不能大于100"),
    PASSWORD_CONFIRM(400104, "两次输入的密码不一致"),
    USERNAME_EXIST(400105, "用户名已存在"),
    UNAUTHORIZED(400106, "你没有权限进行该操作"),
    PASSWORD_INCORRECT(400107, "旧密码不正确"),
    NICKNAME_EMPTY(400108, "昵称不能为空"),
    NICKNAME_LENGTH(400109, "昵称长度大于50"),
    DESCRIPTION_LENGTH(400201, "简介长度不能大于300"),
    PHONE_FORMAT(400202, "电话号码格式不正确"),
    EMAIL_FORMAT(400203, "邮箱格式不正确"),
    PHONE_EXIST(400204, "电话号码已被使用"),
    EMAIL_EXIST(400205, "邮箱已被使用"),
    TITLE_EMPTY(400301, "标题不能为空"),
    TITLE_LENGTH(400302, "标题长度不能大于100"),
    CONTENT_EMPTY(400303, "代码不能为空"),
    CONTENT_LENGTH(400304, "代码长度不能超过10000"),
    BOT_NUM(400305, "每个用户最多只能创建10个Bot"),
    BOT_EXIST(400306, "Bot不存在或已被删除"),

    ;


    public int code;
    public String msg;

    ResultEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ResultEnum getByCode(int codeVal) {
        for (ResultEnum resultCodeEnum : ResultEnum.values()) {
            if (resultCodeEnum.code == codeVal) {
                return resultCodeEnum;
            }
        }
        return null;
    }

}
